import 'package:flutter/cupertino.dart';
import 'package:flutter_base_library/index.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:get/get.dart';
import 'package:safe_manage/config/my_app_data.dart';
import 'package:safe_manage/models/commonRecord.dart';
import '../../../models/eventRecord.dart';

class AlarmHandleController extends GetxController {
  late CommonRecord commonRecord;
  late EventRecord event;
  late String sjlx;
  var handleType = 1; // 1:已处理  2：误报
  final textEditingController = TextEditingController();
  @override
  void onInit() {
    super.onInit();
    Map p = Get.arguments;
    commonRecord = p['record'];
    event = p['event'];
    sjlx = p['sjlx'];
  }

  void bottomButtonClick() {
    // if (textEditingController.text.isEmpty) {
    //   ToastUtils.toast("请输入处理意见");
    //   return;
    // }
    if (sjlx == "2" || sjlx == "8" || sjlx == "9") {
      sjlx = "999";
    }
    Map p = {
      "parameter": {
        "id": event.id,
        "sjlx": sjlx,
        "jlid": event.jlid,
        "clyhid": MyAppData.instance.currentUser!.id,
        "sfcl": handleType,
        "ms": textEditingController.text,
      },
    };
    EasyLoading.show();
    HttpUtils.post(
      "/safety-web/eventRecord/updateById",
      body: p,
      success: (result) {
        Get.back(result: handleType);
        ToastUtils.toast("操作成功");
        EasyLoading.dismiss();
      },
      fail: (errMsg) {
        EasyLoading.dismiss();
      },
    );
  }
}
